﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Messaging;
using System.Web;
using System.Web.Mvc;
using Common;

namespace MessageBus.Controllers
{
    public class MsmqController : Controller
    {
        public MsmqController()
        {
            //todo 验证权限
        }

        public JsonResult Send(BusMessage parm)
        {
            var res=new ApiMessage();
            var mq= BusHelper.GetInstance(parm.BusCode);
            if (mq != null)
            {
                mq.Send(parm.Data, MessageQueueTransactionType.Single);
                res.Success = true;
                res.Message = "发送成功";
            }
            else
            {
                res.Success = false;
                res.Message = "找不到队列";
            }
            return Json(res);
        }

    }
}